package com.myself.ssoserver.entity

import com.myself.common.entity.BaseEntity
import com.myself.common.table.BaseTable
import com.myself.ssoserver.entity.Roles.bindTo
import com.myself.ssoserver.entity.TriLotteries.references
import org.ktorm.database.Database
import org.ktorm.entity.Entity
import org.ktorm.entity.sequenceOf
import org.ktorm.schema.decimal
import org.ktorm.schema.int
import org.ktorm.schema.varchar
import java.math.BigDecimal

interface Nomination : BaseEntity<Nomination> {
    var status: String
    var version: TriVersion
    var user: User
    var planAmount : BigDecimal
    var realAmount : BigDecimal
    var picture : String?
    companion object : Entity.Factory<Nomination>()
}


object Nominations : BaseTable<Nomination>("tri_nomination") {
    val status = varchar("status").bindTo { it.status }
    val planAmount = decimal ("plan_amount").bindTo { it.planAmount }
    val realAmount = decimal ("real_amount").bindTo { it.realAmount }
    val picture = varchar("picture").bindTo { it.picture }
    val versionId = int("version_id").references(TriVersions) { it.version }
    val userId = int("user_id").references(Users) { it.user }
    val Database.nominations get() = this.sequenceOf(Nominations)
}
